package com.hhkj.admin.sale.service.base.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.hhkj.admin.sale.common.cont.SaleCommissionConst;
import com.hhkj.admin.sale.domain.SaleCommission;
import com.hhkj.admin.sale.mapper.SaleCommissionMapper;
import com.hhkj.admin.sale.model.dopo.SaleCommissionCountPo;
import com.hhkj.admin.sale.model.dopo.SaleCommissionDo;
import com.hhkj.admin.sale.model.dopo.SaleCommissionPo;
import com.hhkj.admin.sale.service.base.SaleCommissionService;
import com.ruoyi.common.base.biz.service.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author admin
 * @description 针对表【s_sale_commission(记录每笔分佣情况)】的数据库操作Service实现
 * @createDate 2023-10-27 14:59:05
 */
@Service
public class SaleCommissionServiceImpl
        extends BaseServiceImpl<SaleCommission, SaleCommissionDo, SaleCommissionPo, SaleCommissionMapper>
        implements SaleCommissionService {

    @Override
    public SaleCommissionCountPo countPriceBySaleId(Long saleId) {
        return getBaseMapper().countPriceBySaleId(saleId);
    }

    @Override
    public boolean updateStatusBatchByIdList(List<Long> idList, SaleCommissionConst.StatusCode statusCode) {
        if (ObjectUtil.isEmpty(idList) || ObjectUtil.isEmpty(statusCode)) {
            return false;
        }
        LambdaUpdateWrapper<SaleCommission> updateWrapper = new LambdaUpdateWrapper<SaleCommission>()
                .in(SaleCommission::getId, idList)
                .set(SaleCommission::getStatusCode, statusCode.getCode());
        return update(updateWrapper);
    }
}




